package com.xueyi.aixihu.reqeust;

import com.xueyi.aixihu.exception.SzException;
import com.xueyi.aixihu.reqeust.base.PageLimitReq;
import com.xueyi.aixihu.status.SystemCode;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * @authoer:hxs
 * @createDate:2022/8/18
 * @description: 获取数据库中的微信文章
 */
@Data
public class FindWxArticlesReq extends PageLimitReq {
    /**
     * 标题
     */
    private String title;

    /**
     * 是否展示
     */
    private String isVisibleStr;
    private Integer isVisible;

    private String pageStr;
    private String limitStr;


    public void format() throws SzException {
        try {
            if (!StringUtils.isBlank(this.isVisibleStr))
                this.isVisible = Integer.parseInt(this.isVisibleStr.trim());
            if (!StringUtils.isBlank(this.pageStr))
                this.setPage(Integer.parseInt(this.pageStr.trim()));
            if (!StringUtils.isBlank(this.limitStr))
                this.setLimit(Integer.parseInt(this.limitStr.trim()));
        } catch (NumberFormatException e) {
            throw new SzException(SystemCode.QUERY_CHECK_ERROR, "参数类型错误");
        }

        this.title = StringUtils.isBlank(this.title) ? null : this.title.trim();

    }
}
